<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增工地信息')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-information-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">工地编号：</label>
            <div class="col-sm-8">
                <input name="siteId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">施工单位：</label>
            <div class="col-sm-8">
                <!--<input name="constructionId" class="form-control" type="text">-->
                <select id="constructionId" class="form-control" name="constructionId">
                    <option value="">--请选择施工单位--</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">项目名称：</label>
            <div class="col-sm-8">
                <input name="projectName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">建设单位：</label>
            <div class="col-sm-8">
                <!--                <input name="constructionId" class="form-control" type="text">-->
                <select class="form-control" id="unitId" name="unitId">
                    <option value="">--请选择建设单位--</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">负责人：</label>
            <div class="col-sm-8">
                <input name="leader" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">电话：</label>
            <div class="col-sm-8">
                <input name="phone" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">项目状态：</label>
            <div class="col-sm-8">
                <input name="projectStatus" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">上访人数：</label>
            <div class="col-sm-8">
                <input name="accessNumber" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">风险等级：</label>
            <div class="col-sm-8">
                <input name="riskGrade" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var prefix = ctx + "project/information"

    function initUnitInfo() {
        $.operate.get(ctx + "project/constructionUnit/queryUnitIdName", function (resp) {
            console.log(resp);
            var data = new Array();
            if (resp.code == 0) {
                for (let i = 0; i < resp.data.length; i++) {
                    var item = resp.data[i];
                    var selectItem = {};
                    selectItem.id = item.id;
                    selectItem.text = item.name;
                    data.push(selectItem);
                }
                $("#unitId").select2({
                    data: data,
                    placeholder: "请选择建设单位"
                });
            }
        });
    }

    initUnitInfo();

    function initconstrucId() {
        $.operate.get(ctx + "project/organization/queryOrganizationIdName", function (resp) {
            console.log(resp);
            var data = new Array();
            if (resp.code == 0) {
                for (let i = 0; i < resp.data.length; i++) {
                    var item = resp.data[i];
                    var selectItem = {};
                    selectItem.id = item.id;
                    selectItem.text = item.name;
                    data.push(selectItem);
                }

                $("#constructionId").select2({
                    data: data,
                    placeholder: "请选择施工单位"
                });
            }
        });
    }

    initconstrucId();

    $("#form-information-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-information-add').serialize());
        }
    }
</script>
</body>
</html>